function [best_is,opt_profits,EYI,EYin,ProfitPart] = prop_policy(j_all,N)
    addpath functions;
    global P J I S
    patient_number = size(j_all,2);
    N = min(patient_number,N);%N不能超过给了病种的病人数。
    ProfitPart = zeros(3,N);
    EYI = zeros(1,N);
    EYin = zeros(1,N);
    S = zeros(I, J);
    Line = j_all;
    best_is = zeros(1, N);
    opt_profits = zeros(1, N);
    Q = [ones(I,1),zeros(I,N)];
    R = [ones(I,1),zeros(I,N)];
    for n = 1:N
        j = Line(n);
        profits = zeros(1, I);
        for i = 1:I
            Q_test = findQ2(Q,i,j,P,n); 
            R_test = findR2(Q_test,i,R,n);
            profits(i) = function_fQR2(Q_test,R_test,n);
        end
        i = find(profits == max(profits));
        best_is(n) = i(1);
        i = i(1);
        S(i, j) = S(i, j) + 1;
        Q = findQ2(Q,i,j,P,n);
        R = findR2(Q,i,R,n);
        [opt_profits(n),EYI,EYin,ProfitPart] = function_fQR(Q,R,EYI,EYin,ProfitPart,n);
    end
return